
from selenium import webdriver
from Basic.api_uitest import UiTest_Api as uapi


class Selenium_keyword():

    def __init__(self, driver=None, excel_dict=None):
        if driver is None:
            # 解决您的链接不是私密链接
            options = webdriver.ChromeOptions()
            options.add_argument("--ignore-certificate-errors")
            self.driver = webdriver.Chrome(options=options)
            self.driver.maximize_window()
        else:
            self.driver = driver
        self.get_excel_dict(excel_dict)
        pass

    def get_excel_dict(self, caseDict):
        # 从传入的dict字典获取相关用例的所在行数的所有单元格值
        self.case_module = caseDict['用例模块']
        self.case_id = caseDict['编号']
        self.precondition = caseDict['前提条件']
        self.operate_step = caseDict['操作步骤']
        self.element_operate = caseDict['操作元素']
        self.element_method = caseDict['元素定位方式']
        self.elemernt_action = caseDict['元素动作']
        self.element_sendkey = caseDict['输入数据']
        self.bool_execute = caseDict['是否执行']

        # 断言如何一对多?
        self.assert_ele = caseDict['断言元素']
        self.assert_ele_method = caseDict['断言元素方法']
        self.assert_ele_action = caseDict['断言元素动作']
        self.assert_method = caseDict['断言方法']
        self.except_result = caseDict['预期结果']
        self.assert_result = caseDict['断言结果']
